from .models import Employ,scorer,question,Department
import os


GENDER={
        '管理员':0,
        '书记':1,
        '院长':2,
        '院领导':3,
        '部门负责人':4,
        '其他中层':5,
        '专职教师':6,
        '辅导员':7,
        '普通职工':8,
}

#G=dict(zip(GENDER.values(),GENDER.keys()))
   
class base_department(object):
    '''部门基类'''
    def __init__(self,ID,depart,auth,head,dic):
        self.depart=depart
        self.auth=auth
        self.head=head
        self.dic=dic
        self.ID=ID
        self.analysis_dic={
        '院长':self.get_yuanID_value(),
        '书记':self.get_shujiID_value(),
        '主管院领导':self.get_headyuanID_value(),
        '其他领导':self.get_otherheadyuanID_value(),
        '中层':self.get_middleID_value(),
        '其他':self.get_other_ordinary(),
        }
        '''
        self.yuanz=Employ.objects.filter(employ_auth=G['院长']).employ_ID
        self.shuji=Employ.objects.filter(employ_auth=G['书记']).employ_ID
        self.yuan_value=scorer.objects.filter(scorer_appraiser=self.yuanz,scorer_appraisered=self.ID).scorer_value
        self.shuji_value=scorer.objects.filter(scorer_appraiser=self.shuji,scorer_appraisered=self.ID).scorer_value
        self.zhuguan_value=getyuanID()
        '''
    def base_value(self,var_obj_list,iseval=False):
        var_total=0
        value=0
        #print("start_base_value")
        if len(var_obj_list)==0:
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.first().scorer_value
        #print("end_start_value")
        #print(var_total,len(var_obj_list))
        return var_total/len(var_obj_list)

    def get_yuanID_value(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['院长'])
        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)'''
    def get_shujiID_value(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['书记'])
        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)'''
    def get_headyuanID_value(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['院领导'],employ_name=self.head)
        if(self.head=='金绪泽'):
            var_obj_list=Employ.objects.filter(employ_auth=GENDER['院长'],employ_name=self.head)

        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)'''
    def get_otherheadyuanID_value(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['院领导']).exclude(employ_name=self.head)
        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)'''
    def get_middleID_value(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_ismiddle=1).exclude(employ_ID=self.ID)
        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)'''
    def get_other_ordinary(self):
        var_total=0
        value=0
        var_obj_list=Employ.objects.filter(employ_auth__lte=8, employ_auth__gte=6).exclude(employ_ID=id).exclude(employ_depart=self.depart)
        return self.base_value(var_obj_list)
        '''if len(var_obj_list):
            return 0
        for i in var_obj_list:
            value=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID)
            if(len(value)):
                var_total+=value.scorer_value
        return var_total/len(var_obj_list)
        '''
    def getself(self):
        return self.ID,self.depart,self.auth,self.head
    def get_total_value(self):
        g_list_value=0
        #print(self.ID)
        '''
        fo = open(self.ID+".txt", "a+")
        fo.write(str(self.ID)+'\n')
        fo.write(str(self.dic)+'\n')
        for obj in self.dic:
                g_list_value+=self.get_value_from_dic(obj)*self.dic[obj]

                #print(self.get_value_from_dic(obj),self.dic[obj])
                fo.write(str(self.get_value_from_dic(obj))+"\n")
                fo.write(str(self.dic[obj])+'\n')
        fo.write('总分为:'+str(g_list_value))
        fo.write('\n\n\n')
        fo.close()'''
        for obj in self.dic:
                g_list_value+=self.get_value_from_dic(obj)*self.dic[obj]
                #if(self.get_value_from_dic(obj)==0):
                    #print(self.ID + "error", obj,self.analysis_dic)
        return g_list_value
    def get_value_from_dic(self,obj):
        if(obj in self.analysis_dic):
            return self.analysis_dic[obj]


        return 0

    def get_depart_ordinary(self):
        var_obj_list=Employ.objects.filter(employ_auth__lte=8, employ_auth__gte=6,employ_depart=self.depart).exclude(employ_ID=self.ID)
        #var_obj_list = S.Employ.objects.filter(employ_auth__lte=8, employ_auth__gte=6, employ_depart='图书馆').exclude(employ_ID='xl0013')
        #print(var_obj_list)
        return self.base_value(var_obj_list)
    def get_depart_head(self,depart='None'):
        if(depart!='None'):
            var_obj_list=Employ.objects.filter(employ_auth=GENDER['部门负责人'],employ_depart=depart).exclude(employ_ID=self.ID)
        else:
            var_obj_list=Employ.objects.filter(employ_auth=GENDER['部门负责人'],employ_depart=self.depart).exclude(employ_ID=self.ID)
        return self.base_value(var_obj_list)
    def get_one_value(self,ID='None'):
        var_obj_list=Employ.objects.filter(employ_ID=ID)
        return self.base_value(var_obj_list)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['普通职工']=self.get_depart_ordinary()
            self.analysis_dic['部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['部门负责人']=self.get_depart_head()
        return self.get_total_value()

    '''
    def soft_auth(self):
        g_list=0
        if(self.auth==4):
            
            other_zhuguan_obj_value=getotherID()
            middle_value=getmiddle()
            other_ordinary_value=getother_ordinary()
            depart_other_value=departother()
            str_depart=self.depart+'普通职工'
            g_list=self.dic['院长']*self.yuan_value+self.dic['书记']*self.shuji_value+self.dic['主管院领导']*self.zhuguan_value+self.dic['其他领导']*other_zhuguan_obj_value+self.dic['中层']*middle_value+self.dic['其他']*other_ordinary_value
            g_list+=self.dic[str_depart]*depart_other_value
            
            for obj in dic:
                g_list+=get_value_from_dic(obj)()
        elif(self.auth==5):         
            for obj in dic:
                g_list+=get_value_from_dic(obj)()
        else:
            for obj in dic:
                g_list+=get_value_from_dic(obj)()

        return g_list
    def departother(self):
        a_list=0
        list_u=Employ.objects.filter(employ_depart=self.depart,employ_auth=G['普通职工']).exclude(employ_ID=self.ID)
        if len(list_u):
            for obj in list_u:
                a_list+=scorer.objects.filter(scorer_appraiser=obj.employ_ID,scorer_appraisered=self.ID).scorer_value
        return a_list
    def getmiddle(self):
        a_list=0
        middle=Employ.objects.filter(employ_ismiddle=1).exclude(employ_ID=self.ID)
        if (len(middle)):
            for i in middle:
                a_list+=scorer.objects.filter(scorer_appraiser=i.employ_ID,scorer_appraisered=self.ID).scorer_value
        return a_list
    def getother_ordinary(self):
        a_list=0
        list_u=Employ.objects.filter(employ_auth__lte=8, employ_auth__gte=6).exclude(employ_ID=id)
        for obj in list_u:
            a_list+=scorer.objects.filter(scorer_appraiser=obj.employ_ID,scorer_appraisered=self.ID).scorer_value
        return a_list
    def getotheryuanID(self):
        a_list=0
        zhuguan_obj=Employ.objects.filter(employ_auth=G['院领导']).exclude(employ_name=self.head)
        for obj in zhuguan_obj:
            a_list+=scorer.objects.filter(scorer_appraiser=obj.employ_ID,scorer_appraisered=self.ID).scorer_value
        return a_list
    def getyuanID(self):
        zhuguanyuanlingdao=Employ.objects.filter(employ_auth=G['院领导'],employ_name=self.head).employ_ID
        return scorer.objects.filter(scorer_appraiser=zhuguanyuanlingdao,scorer_appraisered=self.ID).scorer_value
    '''

#保卫部
class defense(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['保卫部普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['保卫部普通职工']=self.get_depart_ordinary()
            self.analysis_dic['保卫部部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['保卫部部门负责人']=self.get_depart_head()
        return self.get_total_value()
        
#党委宣传部
class Party_Committee_Propaganda(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['党委宣传部普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['党委宣传部普通职工']=self.get_depart_ordinary()
            self.analysis_dic['党委宣传部部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['党委宣传部部门负责人']=self.get_depart_head()
        return self.get_total_value()

#党委学生工作部
class Party_Committee_Student_Affairs(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['党委学生工作部普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['党委学生工作部普通职工']=self.get_depart_ordinary()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head()
        return self.get_total_value()

#党委组织部
class Party_Committee_organization(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['党委组织部普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['党委组织部普通职工']=self.get_depart_ordinary()
            self.analysis_dic['党委组织部部门负责人']=self.get_depart_head()
        else:
            #self.analysis_dic['党委组织部部门负责人']=self.get_depart_head
            self.analysis_dic['其他部门普通职工负责人']=self.get_other_head()
        return self.get_total_value()
    def get_other_head(self,iseval=True):
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['部门负责人']).exclude(employ_ID=self.ID,employ_depart=self.depart)
        return self.base_value(var_obj_list,iseval)

#党政办公室
class Party_and_government_office(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['党政办公室普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['党政办公室普通职工']=self.get_depart_ordinary()
            self.analysis_dic['党政办公室部门负责人']=self.get_fazguihuachu_head()
        else:
            self.analysis_dic['党政办公室部门负责人']=self.get_fazguihuachu_head()
        return self.get_total_value()
    def get_fazguihuachu_head(self):
        var_obj_list = Employ.objects.filter(employ_auth=GENDER['部门负责人'],employ_depart='发展规划处').exclude(employ_ID=self.ID)
        return self.base_value(var_obj_list)
#工会办公室
class Trade_union_office(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['秦川']=self.get_one_value(ID='xl0057')
            #self.analysis_dic['党政办公室普通职工']=self.get_depart_ordinary
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['工会办公室普通职工']=self.get_depart_ordinary()
            self.analysis_dic['工会办公室部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['工会办公室部门负责人']=self.get_depart_head()
        return self.get_total_value()

#教师发展与教学研究中心
class Teacher_Development_and_Teaching_Research_Center(base_department):
    def __init__(self,name,depart,auth,head,dic,teacher=0,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.teacher=teacher
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['教师发展与教学研究中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['教师发展与教学研究中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['教师发展与教学研究中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['教师发展与教学研究中心部门负责人']=self.get_depart_head()
            self.analysis_dic['教务处部门负责人']=self.get_depart_head(depart='教务处')
            #self.analysis_dic['督导教师评教']=self.teacher
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#教务处
class dean_s_office(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['教务处普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['教务处普通职工']=self.get_depart_ordinary()
            self.analysis_dic['教务处部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['教务处部门负责人']=self.get_depart_head()
        return self.get_total_value()

#教育科学学院
class School_of_Educational_Sciences(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['教育科学学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['教育科学学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['教育科学学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['教育科学学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#经济与管理学院
class Institute_of_economics_and_management(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['经济与管理学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['经济与管理学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['经济与管理学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['经济与管理学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#经营中心
class Business_center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['经营中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['经营中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['经营中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['经营中心部门负责人']=self.get_depart_head()
        return self.get_total_value()

#就业创业服务中心
class Employment_and_entrepreneurship_service_center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['就业创业服务中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['就业创业服务中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['就业创业服务中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['就业创业服务中心部门负责人']=self.get_depart_head()
        return self.get_total_value()

#老校区办公室
class Old_campus_office(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['老校区办公室普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['老校区办公室普通职工']=self.get_depart_ordinary()
            self.analysis_dic['老校区办公室部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['老校区办公室部门负责人']=self.get_depart_head()
        return self.get_total_value()

#理工学院
class Polytechnic(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['理工学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['理工学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['理工学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['理工学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#人力资源处
class Human_resources_division(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['人力资源处普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['人力资源处普通职工']=self.get_depart_ordinary()
            self.analysis_dic['人力资源处部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['人力资源处部门负责人']=self.get_depart_head()
        return self.get_total_value()

#人文与艺术学院
class College_of_arts_and_humanities(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['人文与艺术学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['人文与艺术学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['人文与艺术学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['人文与艺术学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#数学与计算机科学学院
class Mathematics_and_computer_science(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['数学与计算机科学学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['数学与计算机科学学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['数学与计算机科学学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['数学与计算机科学学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#图书馆
class Library(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['图书馆普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['图书馆普通职工']=self.get_depart_ordinary()
            self.analysis_dic['图书馆部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['图书馆部门负责人']=self.get_depart_head()
        return self.get_total_value()

#团委
class Corps_committee(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['团委普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['团委普通职工']=self.get_depart_ordinary()
            self.analysis_dic['团委部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['团委部门负责人']=self.get_depart_head()
        return self.get_total_value()

#现代教育技术中心
class Modern_education_Technical_Center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['现代教育技术中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['现代教育技术中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['现代教育技术中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['现代教育技术中心部门负责人']=self.get_depart_head()
        return self.get_total_value()

#校园中心
class Campus_Center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['综合科和校园中心普通职工']=(self.get_depart_ordinary()+self.get_zhongheke())/2
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['校园中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['校园中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['校园中心部门负责人']=self.get_depart_head()
        return self.get_total_value()
    def get_zhongheke(self):
        #vsr_obj_list=Employ.objects.filter(employ_auth=GENDER['普通职工'],employ_depart='综合科').exclude(employ_ID=self.ID)
        var_obj_list = Employ.objects.filter(employ_auth__lte=8, employ_auth__gte=6, employ_depart='综合科').exclude(employ_ID=self.ID)
        return self.base_value(var_obj_list)

#心理健康教育与咨询中心
class Mental_health_education_and_counseling_center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['心理健康教育与咨询中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['心理健康教育与咨询中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['心理健康教育与咨询中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['心理健康教育与咨询中心部门负责人']=self.get_depart_head()
        return self.get_total_value()

#饮食中心
class Diet_center(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['饮食中心普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['饮食中心普通职工']=self.get_depart_ordinary()
            self.analysis_dic['饮食中心部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['饮食中心部门负责人']=self.get_depart_head()
        return self.get_total_value()

#招生办公室
class Office_of_Admissions_and_Records(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['招生办公室普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['招生办公室普通职工']=self.get_depart_ordinary()
            self.analysis_dic['招生办公室部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['招生办公室部门负责人']=self.get_depart_head()
        return self.get_total_value()

#政法学院
class Political_Science_and_Law(base_department):
    def __init__(self,name,depart,auth,head,dic,student=0):
        super().__init__(name,depart,auth,head,dic)
        self.student=student
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['政法学院辅导员']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['政法学院辅导员']=self.get_depart_ordinary()
            self.analysis_dic['政法学院部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['政法学院部门负责人']=self.get_depart_head()
            self.analysis_dic['党委学生工作部部门负责人']=self.get_depart_head('党委学生工作部')
            #self.analysis_dic['所带班级学生']=self.student
        return self.get_total_value()

#资产管理处
class Office_of_Foreign_Assets_Control(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['资产管理处普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['资产管理处普通职工']=self.get_depart_ordinary()
            self.analysis_dic['资产管理处部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['资产管理处部门负责人']=self.get_depart_head()
        return self.get_total_value()

#综合科
class Comprehensive_department(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['综合科普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['综合科普通职工']=self.get_depart_ordinary()
            self.analysis_dic['综合科部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['校园中心部门负责人']=self.get_xiaouan_head()
        return self.get_total_value()
    def get_xiaouan_head(self):
        var_obj_list = Employ.objects.filter(employ_auth=GENDER['部门负责人'], employ_depart='校园中心').exclude(employ_ID=self.ID)
        return self.base_value(var_obj_list)

#财务点
class Financial_point(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['财务点普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['财务点普通职工']=self.get_depart_ordinary()
            self.analysis_dic['财务点部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['其他部门普通职工负责人']=self.get_other_head()
        return self.get_total_value()
    def get_other_head(self,iseval=True):
        var_obj_list=Employ.objects.filter(employ_auth=GENDER['部门负责人']).exclude(employ_ID=self.ID,employ_depart=self.depart)
        return self.base_value(var_obj_list,iseval)

#'发展规划处'
class Development_planning_office(base_department):
    def __init__(self,name,depart,auth,head,dic):
        super().__init__(name,depart,auth,head,dic)
    def soft_auth(self):
        if(self.auth==GENDER['部门负责人']):
            self.analysis_dic['党政办公室普通职工']=self.get_depart_ordinary()
        elif(self.auth==GENDER['其他中层']):
            self.analysis_dic['党政办公室普通职工']=self.get_depart_ordinary()
            self.analysis_dic['党政办公室部门负责人']=self.get_depart_head()
        else:
            self.analysis_dic['党政办公室部门负责人']=self.get_depart_head()
        return self.get_total_value()



depart_class_list={
    '基础部门':base_department,
    '保卫部':defense,
    '党委宣传部':Party_Committee_Propaganda,
    '党委学生工作部':Party_Committee_Student_Affairs,
    '党委组织部':Party_Committee_organization,
    '党政办公室':Party_and_government_office,
    '工会办公室':Trade_union_office,
    '教师发展与教学研究中心':Teacher_Development_and_Teaching_Research_Center,
    '教务处':dean_s_office,
    '教育科学学院':School_of_Educational_Sciences,
    '经济与管理学院':Institute_of_economics_and_management,
    '经营中心':Business_center,
    '就业创业服务中心':Employment_and_entrepreneurship_service_center,
    '老校区办公室':Old_campus_office,
    '理工学院':Polytechnic,
    '人力资源处':Human_resources_division,
    '人文与艺术学院':College_of_arts_and_humanities,
    '数学与计算机科学学院':Mathematics_and_computer_science,
    '图书馆':Library,
    '团委':Corps_committee,
    '现代教育技术中心':Modern_education_Technical_Center,
    '校园中心':Campus_Center,
    '心理健康教育与咨询中心':Mental_health_education_and_counseling_center,
    '饮食中心':Diet_center,
    '招生办公室':Office_of_Admissions_and_Records,
    '政法学院':Political_Science_and_Law,
    '资产管理处':Office_of_Foreign_Assets_Control,
    '综合科':Comprehensive_department,
    '财务点':Financial_point,
    '发展规划处':Development_planning_office,
}